// 封装高阶组件
// 核心逻辑： 有token 正常跳转到页面，无token 跳转到登录页
import { getToken } from '@/utils'
import { Navigate } from 'react-router-dom'

type PropType = {
  children?: React.ReactNode
}

const AuthRoute: any = ({ children }: PropType) => {
  const token = getToken()
  if (token) {
    return (<>{children}</>)
  } else {
    return <Navigate to={'/login'} replace />
  }
}

export default AuthRoute